//LICENSE START
// Developed by: Sourabh Jain (sourj@cs.umn.edu), Gowri CP, Zhi-Li Zhang
// Copyright (c) 2010 All rights reserved by Regents of University of Minnesota
//LICENSE END
#include <click/config.h>
#include <click/confparse.hh>
#include <click/error.hh>
#include <click/straccum.hh>
#include "virtualnetworkID.hh"

CLICK_DECLS

VEILVirtualNetworkID::VEILVirtualNetworkID () {}

VEILVirtualNetworkID::~VEILVirtualNetworkID () {}

int 
VEILVirtualNetworkID::configure(Vector<String> &conf, ErrorHandler *errh)
{
	int vnidint;
	int r = 0;
	int i = 0;
	if(cp_integer(conf[i], &vnidint)){
		virnetid = (VNID) vnidint;
	} 
	else {
		errh->error("[VirtualNetworkID][Error!]error in processing VNID argument in VEILVirtualNetworkID, Virtual Network Value is within 0 - 65535!");
		r = -EINVAL;
	}

	i++;
	cp_shift_spacevec(conf[i]);
	String printflag = cp_shift_spacevec(conf[i]);
	if(!cp_bool(printflag, &printDebugMessages))
		return errh->error("[## VirtualNetworkID **] [Error] PRINTDEBUG FLAG should be either true or false");	
	return r;
}


String
VEILVirtualNetworkID::read_handler(Element *e, void *thunk)
{
	StringAccum sa;
	VEILVirtualNetworkID *it = (VEILVirtualNetworkID *) e;
	VNID vnid = static_cast<VNID>(it->virnetid);
	
	sa << "\n" << "Virtual Network ID : " << vnid << "\n";

	return sa.take_string();
}

void
VEILVirtualNetworkID::add_handlers()
{
	add_read_handler("value", read_handler, (void *)0);
}

CLICK_ENDDECLS

EXPORT_ELEMENT(VEILVirtualNetworkID)
